DefaultStatesMachine

class DefaultStatesMachine<T : State>(statesManager: StatesManager<T>, handlers: List<CustomizableHandlerHolder<in T, T>>) : StatesMachine<T>

Default realization of StatesMachine. It uses statesManager for incapsulation of States storing and contexts resolving, and uses launchStateHandling for State handling

Constructors

DefaultStatesMachine
Link copied to clipboard
fun <T : State> DefaultStatesMachine(statesManager: StatesManager<T>, handlers: List<CustomizableHandlerHolder<in T, T>>)

Functions

handleState
Link copied to clipboard
open suspend override fun StatesMachine<in T>.handleState(state: T): T?

Will call launchStateHandling for state handling

launchStateHandling
Link copied to clipboard
open suspend fun launchStateHandling(state: T, handlers: List<CustomizableHandlerHolder<in T, T>>): T?
start
Link copied to clipboard
open override fun start(scope: CoroutineScope): Job

Launch handling of states. On statesManager, statesManager will be called lambda with performing of state. If launchStateHandling will returns some State then statesManager will be used, otherwise StatesManager.endChain.

startChain
Link copied to clipboard
open suspend override fun startChain(state: T)

Just calls StatesManager.startChain of statesManager